function validarPasswordRole(){
    var pass1 = $("#id_claveRole").val();
    var pass2 = $("#id_claveRole2").val();
    //alert("pass: "+pass1+", pass2: "+pass2);
    
    if(pass1 != null && pass2 != null && pass1 != "" && pass2 != ""){
        if(pass1 == pass2){
            
            return pass1;
        }else{
            
            return 1;
        }
        
    }else{
        return 2;
    }
}

function pass_error(val){
    var ret = "";
    var fl = false;
    switch (val)
    {
        case 1:
            ret = "Claves no coinciden";
            break;
        case 2:
            ret = "Clave(s) vacía(s)";
            break;
        default:
            ret = "Clave correctactamente asignada"; 
            fl = true;
            break;
            
        
    }
    activar_modal(2,ret);// se puede cambiar po un alert
    return fl;
}
function getRole(){
    var query, privilegios, roles;
    var role_name = $("#id_Role").val();
    if(role_name != "" &&  role_name != null){
        
        
        var tipo_indentificacion = $("#id_IDENTIFIED_").find('option:selected').text();
        if(tipo_indentificacion != null && tipo_indentificacion != ""){
        
            if("IDENTIFIED BY"==tipo_indentificacion){
                var pw = validarPasswordRole();
                var pw_valida = pass_error(pw);
                console.log(pw_valida);
                if(pw_valida){
                    query = "CREATE ROLE "+role_name+" "+tipo_indentificacion+" "+pw+"; ";
                    privilegios = getDataTable("tabla-agrega-rol");
                    roles = getDataTable("tabla-agrega-rol-roles");
                    var ajax = [role_name, query, privilegios, roles];
                    console.log(ajax);
                    return ajax;
                    
                }else{
                    activar_modal(2,"Password Inválida");
                    console.log("Clave invalidad");
                    
                }
                
            }else{
                query = "CREATE ROLE "+role_name+" "+tipo_indentificacion+"; ";
                privilegios = getDataTable("tabla-agrega-rol");
                roles = getDataTable("tabla-agrega-rol-roles");
                var ajax = [role_name, query, privilegios, roles];
                console.log(ajax);
                return ajax;
            }
                
        }
    }
    
   
    
    
    
    
}